#include<iostream>
#include<vector>

using std::cin;
using std::cout;
using std::vector;
using std::endl;

template<typename T>
void Create_a_graph(int &n, int &a, int &b, vector<vector<T>> &v) {
    cin >> n;
    v.resize(2 * n);
    cin >> a >> b;
    for (int i = 0; i < a; ++i) {
        int first, second;
        cin >> first >> second;
        v[2 * (first - 1)].push_back(2 * first - 1);
        v[2 * (second - 1)].push_back(2 * second - 1);
        v[2 * first - 1].push_back(2 * (second - 1));
    }

    for (int i = 0; i < b; ++i) {
        int first, second;
        cin >> first >> second;
        v[2 * (first - 1)].push_back(2 * second - 1);
        v[2 * (second - 1)].push_back(2 * first - 1);
    }
}

template<typename T>
void Top_Sort(T vertex, const vector<vector<T>> &v, vector<T> &used,
    vector<T> &order, bool &flag, T pred) {
    used[vertex] = 1;
    for (int i = 0; i < v[vertex].size(); ++i) {
        T to = v[vertex][i];
        if (used[to] == 0) {
            Top_Sort(to, v, used, order, flag, vertex);
        }
        if (used[to] == 1) {
            flag = true;
            return;
        }
    }
    order.push_back(vertex / 2);
    used[vertex] = 2;
}

struct point{
    int first;
    int second;
};

template<typename T>
void Solve(const vector<T> &order, bool fl) {
    if (fl) {
        cout << "Impossible";
        return;
    }
    vector<point> res;
    res.resize(order.size() / 2);
    for (int i = 0; i < res.size(); ++i) {
        res[i].first = res[i].second = 0;
    }
    int count = 1;
    for (int i = order.size() - 1; i >= 0; --i) {
        int ver = order[i];
        if (res[ver].first == 0) {
            res[ver].first = count++;
        }
        else {
            res[ver].second = count++;
        }
    }
    for (int i = 0; i < res.size(); ++i) {
        cout << res[i].first << " " << res[i].second << endl;
    }
}

int main() {
    int n, a, b;
    vector<vector<int>> v;
    vector<int> used;
    vector<int> order;
    bool flag = false;

    Create_a_graph(n, a, b, v);
    used.resize(v.size());
    for (int i = 0; i < v.size(); ++i) {
        if (used[i] == 0) {
            Top_Sort(i, v, used, order, flag, i);
        }
    }

    Solve(order, flag);
}